home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / qbware.exe / PULLDOWN.BAS < prev    next >
BASIC Source File  |  1990-11-30  |  4KB  |  184 lines

  1. '*****************************************************************************
  2. '
  3. '   PullDown.Bas
  4. '
  5. '*****************************************************************************
  6.  
  7. 'Copyright (c) 1988 Marcel Madonna
  8.  
  9. 'PULLDOWN.BAS shows the use of pulldown menus
  10. '  with QBWARE.
  11. '*****************************************************************************
  12.  
  13.  
  14.     OPTION BASE 1
  15.  
  16.  
  17. ' Dim arrays for QB Syntax check only - we REDIM them later
  18.  
  19.  
  20.     x% = 1
  21.     DIM Text$(x%), MenuText$(x%), Location%(x%, 2), TColors%(x%, 2), TLength%(x%)
  22.     DIM TblData$(x%), TblSlct%(x%), SText$(x%)
  23.  
  24.  
  25. ' Set up housekeeping for window drivers
  26.  
  27.     DIM MenuList$(6, 6)
  28.     StackSize% = 20000
  29.     DIM WinStack%(StackSize%)       'Window stack - we keep screen images
  30.                     'and other info here
  31.     DIM WinFrame%(20, 5)            'Define maximum number of windows as 20
  32.                     'we keep specific window data here
  33.     GOSUB A1000.Window.Hskp
  34.  
  35.  
  36. ' Now let's display the pulldown menu
  37.  
  38.     MenuNum% = 0    'Means display only the top line
  39.             'and return immediately to this program
  40.  
  41.     GOSUB Display.PullDown
  42.  
  43.  
  44. ' Let's wait for some input and then route it the the proper routine
  45.  
  46. WaitForInput:
  47.  
  48.     LOCATE , , 0    'Turn the cursor off
  49.     CALL InpWin(WinStack%(), Input.Char$, 0)
  50.     MenuNum% = INSTR(KeyFlds$, Input.Char$)
  51.     IF MenuNum% = 0 OR LEN(Input.Char$) <> 2 THEN
  52.         GOTO WaitForInput
  53.     ELSE
  54.         MenuNum% = INT((MenuNum% / 2) + 1)
  55.         GOTO Display.PullDown
  56.     END IF
  57.     LOCATE , , 1    'Turn the cursor back on
  58.  
  59.  
  60. Display.PullDown:
  61.  
  62.     Tr% = 1: Fg% = 0: Bg% = 3
  63.  
  64. 'This call displays the pulldown menu
  65.     CALL PullDown(WinStack%(), WinFrame%(), WinPoint%, MenuList$(), MenuNum%, Tr%, Fg%, Bg%, MFg%, MBg%, RtnMnu%, RtnItm%)
  66.  
  67. 'This next statement routes the request the the proper routine
  68. 'If MenuNum% was 0 on input to pulldown, then RtnMnu% = 0 and we will drop
  69. ' right thru the ON statement here
  70.     ON RtnMnu% GOSUB Menu1, Menu2, Menu3, Menu4, Menu5, Menu6
  71.  
  72.     GOTO WaitForInput
  73.  
  74. Menu1:
  75.     ON RtnItm% GOTO Menu11, Menu12, Menu13, Menu14, Menu15
  76.  
  77. Menu2:
  78.     ON RtnItm% GOTO Menu21, Menu22, Menu23, Menu24, Menu25
  79.  
  80. Menu3:
  81.     ON RtnItm% GOTO Menu31, Menu32, Menu33, Menu34, Menu35
  82.  
  83. Menu4:
  84.     ON RtnItm% GOTO Menu41, Menu42, Menu43, Menu44, Menu45
  85.  
  86. Menu5:
  87.     ON RtnItm% GOTO Menu51, Menu52, Menu53, Menu54, Menu55
  88.  
  89. Menu6:
  90.     ON RtnItm% GOTO Menu61, Menu62, Menu63, Menu64, Menu65
  91.  
  92. Menu11:
  93. Menu12:
  94. Menu13:
  95. Menu14:
  96. Menu15:
  97.  
  98. Menu21:
  99. Menu22:
  100. Menu23:
  101. Menu24:
  102. Menu25:
  103.  
  104. Menu31:
  105. Menu32:
  106. Menu33:
  107. Menu34:
  108. Menu35:
  109.  
  110. Menu41:
  111. Menu42:
  112. Menu43:
  113. Menu44:
  114. Menu45:
  115.  
  116. Menu51:
  117. Menu52:
  118. Menu53:
  119. Menu54:
  120. Menu55:
  121.  
  122. Menu61:
  123. Menu62:
  124. Menu63:
  125. Menu64:
  126. Menu65:
  127.  
  128.     CLS
  129.     PRINT "You selected item" + STR$(RtnItm%)
  130.     PRINT "From menu" + STR$(RtnMnu%)
  131.     END
  132.  
  133.  
  134. A1000.Window.Hskp:
  135.  
  136. ' Load the menu itwms
  137.  
  138.     RESTORE MainMenu.Data
  139.     FOR x% = 1 TO UBOUND(MenuList$, 2)
  140.         FOR y% = 1 TO UBOUND(MenuList$, 1)
  141.             READ MenuList$(y%, x%)
  142.         NEXT y%
  143.     NEXT x%
  144.  
  145. 'Set up the posible keys that can be returned
  146.  
  147.     Alt.A$ = CHR$(0) + CHR$(30)     'Alt-A keycode
  148.     Alt.B$ = CHR$(0) + CHR$(48)     'Alt-B keycode
  149.     Alt.C$ = CHR$(0) + CHR$(46)     'Alt-C keycode
  150.     Alt.D$ = CHR$(0) + CHR$(32)     'Alt-D keycode
  151.     Alt.E$ = CHR$(0) + CHR$(18)     'Alt-E keycode
  152.     Alt.F$ = CHR$(0) + CHR$(33)     'Alt-F keycode
  153.     
  154.     KeyFlds$ = Alt.A$ + Alt.B$ + Alt.C$ + Alt.D$ + Alt.E$ + Alt.F$
  155.  
  156.     Text$ = STRING$(2000, CHR$(176))
  157.     Row% = 1: Col% = 1: Fg% = 0: Bg% = 1
  158.     CALL Putline(Snow%, Text$, Row%, Col%, Fg%, Bg%)
  159.     Text$ = ""
  160.  
  161.     MFg% = 15: MBg% = 0
  162.     MaxWin% = 20
  163.     ExitKeys$ = CHR$(27)
  164.     TabLen% = 8
  165.     SBar% = 1: SRow% = 25: SFg% = 15: Sbg% = 1
  166.  
  167.     CALL InitWin(WinStack%(), WinFrame%(), WinPoint%, MaxWin%, ExitKeys$, TabLen%, SBar%, SRow%, SFg%, Sbg%, Snow%)
  168.     RETURN
  169.  
  170. ' These are the menu choices.  The first item appears on the bar and the items
  171. ' below appear on the pulldown menu.  Each column must have EXACTLY the same
  172. ' number of entries - even if some are null
  173.  
  174. MainMenu.Data:
  175.     DATA "AMenu","BMenu","CMenu","DMenu","EMenu","FMenu"
  176.     DATA "AItem","AItem","AItem","AItem","AItem","AItem"
  177.     DATA "BItem","BItem","BItem","BItem","BItem","BItem"
  178.     DATA "CItem","CItem","CItem","CItem","CItem","CItem"
  179.     DATA "DItem","DItem","DItem","DItem","DItem","DItem"
  180.     DATA "EItem","EItem","EItem","EItem","EItem","EItem"
  181.  
  182.     END
  183.  
  184.